package com.gzx.bi.modular.plan.mapper;

import com.gzx.bi.modular.plan.entity.GzxProjectPlan;
import com.gzx.bi.modular.plan.vo.GzxProjectPlanVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import vip.xiaonuo.common.mapper.BaseMapperPlus;

/**
 * @author zjt
 * @description
 * @since 2025/4/27 16:23
 */
public interface GzxProjectPlanMapper extends BaseMapperPlus<GzxProjectPlan, GzxProjectPlanVo> {

    @Update({"<script>",
            "UPDATE gzx_project_plan a",
            "INNER JOIN gzx_project_plan b",
            "   ON a.project_code = b.project_code",
            "   AND a.batch = b.batch",
            "SET",
            "   a.last_entrust_amt = b.entrust_amt,",
            "   a.last_entrust_cnt = b.entrust_cnt,",
            "   a.last_staff_cnt = b.staff_cnt,",
            "   a.last_repay_target = b.repay_target,",
            "   a.last_comm_ratio = b.comm_ratio",
            "WHERE",
            "   a.belonging_month = #{currentMonth}",
            "   AND b.belonging_month = #{lastMonth}",
            "</script>"})
    void saveLastMonthData(@Param("currentMonth") Integer currentMonth, @Param("lastMonth") Integer lastMonth);
}
